package com.securinets.news;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.securinets.R;
import com.securinets.BD.ArticlesDBAdapter;

public class NewsActivity extends ListActivity {
	
	ArrayList<Article> articles = new ArrayList<Article>();

	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	       
	        ArticlesDBAdapter DB = new ArticlesDBAdapter(this);
	        DB.open();
//	        DB.insertArticle(new Article(null, "image", "Article1", "Description sur l'article 1"));
//	        DB.insertArticle(new Article(null, "image", "Article2", "Description sur l'article 2"));
//	        DB.insertArticle(new Article(null, "image", "Article3", "Description sur l'article 3"));
//	        DB.insertArticle(new Article(null, "image", "Article4", "So shaken as we are, so wan with care Find we a time for frighted peace to pant And breathe short-winded accents of new broils To be commenced in strands afar remote No more the thirsty entrance of this soil Shall daub her lips with her own children's blood"));
//	        DB.insertArticle(new Article(null, "image", "Article5", "So shaken as we are, so wan with care Find we a time for frighted peace to pant And breathe short-winded accents of new broils To be commenced in strands afar remote No more the thirsty entrance of this soil Shall daub her lips with her own children's blood"));
	        
	        articles = DB.getAllArticles();
	        //articles.add(DB.getArticle(2));
	        DB.close();
	        
	        MyAdapter adpt = new MyAdapter(this, articles);
	        setListAdapter(adpt);
	        	        
	    }

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// Request the next activity transition (here starting a new one).
		Intent intent  = new Intent(NewsActivity.this, ArticleDescription.class);
		intent.putExtra("Desc", articles.get(position).description);
        startActivity(intent);
        overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
	}
	 
	 
	   
}
